import request from '@/api/request.js';

export function login(user){
	return new Promise((resolve, reject) =>{
		request('/login', 'POST', user)
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function register(user){
	return new Promise((resolve, reject) =>{
		request('/register', 'POST', user)
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function getLoanProducts(){
	return new Promise((resolve, reject) =>{
		request('/loanproduct', 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function addPerson(person){
	return new Promise((resolve, reject) =>{
		request('/person', 'POST', person)
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function getPersonInfo(){
	return new Promise((resolve, reject) =>{
		request('/person', 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}


export function updatePerson(person){
	return new Promise((resolve, reject) =>{
		request('/person', 'PUT', person)
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function addEnterprise(enterprise){
	return new Promise((resolve, reject) =>{
		request('/enterprise', 'POST', enterprise)
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function getEnterpriseInfo(){
	return new Promise((resolve, reject) =>{
		request('/enterprise', 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}


export function updateEnterprise(enterprise){
	return new Promise((resolve, reject) =>{
		request('/enterprise', 'PUT', enterprise)
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}

export function getUserStatus(){
	return new Promise((resolve, reject) =>{
		request('/account-status', 'GET')
		  .then((res) => {
		    resolve(res);
		  })
		  .catch((err) => {
		    reject(err);
		  });
	})
}